<template>
 <view class="main" @touchstart="touchStart" @touchend="touchEnd">
	 <view class="pleft" @click="jumpindex">
	 	<image src="https://ppp.new.zeroitem.cn/ppp/pleft1.png" class="limg"></image> 
	 </view>
  <view class="part1">今日有{{psdetail.pnum}}单拍摄</view> 
  <view class="part2">
	  <image :src="psdetail.avatar" class="img1"></image>
	  <view class="part2-1">
		<view class="txt1">{{psdetail.xm}}</view>  
		<view class="txt2" @click="dingwei">
		<image src="https://ppp.new.zeroitem.cn/ppp/ps/3.png" style="width:40rpx;height:40rpx;padding-right:10rpx;"></image>
		{{psdetail.bd.result.addressComponent.city}}.{{psdetail.bd.result.addressComponent.district}} ></view>
	  </view>
  </view>
  <view class="part3 p1" @click="jumpmenu(1)">
	<image src="https://ppp.new.zeroitem.cn/ppp/my/4.png" class="img2"></image>
	 接单记录
  </view>
 <view class="part3 p2" @click="qb()">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/2.png" class="img2"></image>
 	 钱包
 </view> 
 <view class="part3 p2" @click="jumpmenu(3)">
 	<image src="https://ppp.new.zeroitem.cn/ppp/cp1.png" class="img2"></image>
 	 拍手认证({{psdetail.shenzt}})
 </view> 
 
 
 <view class="part3 p2" @click="jumpmenu(6)">
 	<image src="https://ppp.new.zeroitem.cn/ppp/cp3.png" class="img2"></image>
 	 个人简介
 </view>
 
 <view class="part3 p2" @click="jumpmenu(7)">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/5.png" class="img2"></image>
 	 我的分享
 </view>  
 <button class="part3 p2" open-type="contact">
 	<image src="https://ppp.new.zeroitem.cn/ppp/my/3.png" class="img2"></image>
 	 联系客服
 </button>   
  <view class="part3 p2" @click="sz();">
  	<image src="https://ppp.new.zeroitem.cn/ppp/my/6.png" class="img2"></image>
  	 设置
  </view> 
  <view class="part4" @click="qhkh();">
	转换为客户 
  </view>
   <view class="mask" v-if="zt==1" style="z-index:100000">
      <view class="qtc">
		<view class="tctxt-2 txt6">是否切换为客户</view> 
		<view class="tcbtn1 btnm">
		  <view class="tcbtn btn1" @click="qhkh1();">否</view>
		  <view class="tcbtn btn2" @click="qhkh2();">是</view>
		</view>
	  </view>
   </view>
  
  
 </view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {
	   psdetail,savepsaddress
	} from '@/api/ppp'
	const app = getApp()
	export default {
	    data() {
	        return {
	         zt:0,
			 psdetail:[]
	        }
	    },
		onShow(){
         this.getpsdetail();
		},
	    methods: {
			dingwei(){
			  var that=this;
			  uni.chooseLocation({
			  	success:(res)=> {
			  	  that.address=res.address;
			  	  that.latitude=res.latitude;
			  	  that.longitude=res.longitude;
				  that.savepsaddress1({address:res.address,lat:res.latitude,lng:res.longitude})
			  	}
			   })
			},
			async savepsaddress1(data){
			  var that=this;
			  const{
			   code,
			   msg,
			   data1
			  }= await savepsaddress(data);
			  if(code==1){
			    that.getpsdetail();
			  }  	
			},
			touchStart: function (e) {
				if (e.touches.length == 1) {
					//设置触摸起始点水平方向位置
					this.startX=e.touches[0].clientX;
				}
			  },
			/**
			 * 触摸结束
			 * @param {Object} e
			 */
			touchEnd: function (e) {
				if (e.changedTouches.length == 1) {
					//手指移动结束后水平位置
					var endX = e.changedTouches[0].clientX;
					let diff = endX-this.startX;
					if(Math.abs(diff)>20){
						if(diff>0){
						  uni.redirectTo({
						  	url:"/pages/ppp/ps1/dqzz"
						  })
						}else{
						 uni.redirectTo({
						 	url:"/pages/ppp/ps1/dqzz"
						 })
						}
					}
				}
			
			},	
			jumpindex(){
			 uni.redirectTo({
			 	url:"/pages/ppp/ps1/dqzz"
			 })	
			},
			qhkh(){
			//this.zt=1;
			uni.navigateTo({url:"/pages/ppp/index/drps"})
			},
			qhkh1(){this.zt=0;},
			qhkh2(){uni.navigateTo({url:"/pages/ppp/my/index"}) },
			sz(){uni.redirectTo({url:"/pages/user_profile/user_profile"}) },
			qb(){uni.redirectTo({url:"/pages/user_wallet/user_wallet"}) },
			async getpsdetail(){
			  const{
			     data
			   }= await psdetail({});
			  this.psdetail=data;
			},
			jumpmenu(type){
			 if(type==4 || type==5 || type==6 || type==1){
			   if(this.psdetail.flag!=2){
				 uni.showToast({title:"当前拍手认证中，认证通过后才可以查看",icon:"none"});
					 return false;
			   }
		       if(type==5){
		       	  uni.redirectTo({url:"/pages/ppp/ps1/dqzz"})    
		       }
		      if(type==6){
		       uni.redirectTo({url:"/pages/ppp/ps/psinfo?from=menu"})
		       }			   
		       if(type==4){
		   		 uni.redirectTo({url:"/pages/ppp/ps/main1"})    
		       }	 		    
			 }
			 if(type==3){
			  uni.redirectTo({url:"/pages/ppp/ps/psrz"	}) 
			 }
			 if(type==1){
			  uni.redirectTo({url:"/pages/ppp/ps/jjjl"	})  
			 }
			 if(type==7){
			  uni.redirectTo({url:"/pages/ppp/my/share1"	}) 
			 }				 
				 
				 
			}
	    },
		computed: {
			...mapGetters(['isLogin', ]),
		}		
		
	}
</script>


<style>
@import "./menu.css";	
</style>
